/*
 * @FileDescription: 工具函数
 * @Author: zsf
 * @Date: 2021-05-03 10:58:11
 * @LastEditors: zsf
 * @LastEditTime: 2021-05-03 11:16:14
 */
import moment from 'moment';

/**
 * 获取最近7天时间 不加上今天
 * @returns [开始时间, 结束时间]
 */
export const get7Data = function () {
  //Last 7 days
  let nowTemp = new Date();
  let c_time = nowTemp.getTime(); //当前时间的毫秒时间，时间戳
  let oneDayLong = 24 * 60 * 60 * 1000; //一天的毫秒数
  let set01 = new Date(c_time - oneDayLong * 7);
  let set02 = new Date(c_time - oneDayLong * 1);
  let s1 =
    set01.getFullYear() +
    "-" +
    (set01.getMonth() + 1) +
    "-" +
    set01.getDate();
  let s2 =
    set02.getFullYear() +
    "-" +
    (set02.getMonth() + 1) +
    "-" +
    set02.getDate();
  return [moment(new Date(s1)), moment(new Date(s2))];
}
